package interview.huawei.tjt.training.huaweijishitiku;

import java.util.Scanner;
import java.util.Set;
import java.util.TreeSet;

// 整形数组合并
public class HJ80 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while ( sc.hasNextInt() ) {
            Set<Integer> set = new TreeSet<>();
            int n = sc.nextInt();
            for ( int i = 0; i < n; i ++ ) {
                set.add(sc.nextInt());
            }
            int m = sc.nextInt();
            for ( int i = 0; i < m; i ++ ) {
                set.add(sc.nextInt());
            }

            StringBuffer stringBuffer = new StringBuffer();
            for ( int i: set) {
                stringBuffer.append(i);
            }

            System.out.println(stringBuffer);
        }
    }

}
